from time import time

def fntimer(times, fun, *args, **kwargs):
	t = time()
	for i in xrange(times):
		fun(*args, **kwargs)
	return time() - t

def timeonce(fun, *args, **kwargs):
	"""Time fun and return (time, rval)"""
	t = time()
	r = fun(*args, **kwargs)
	return (time()-t, r)

			 
